package com.pxx.item.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * mybatis 分页配置类
 */
/**
 * @author : Yoo19
 * @description :
 * @createDate : 2025/6/23 21:09 09
 */
@Configuration
public class MyBatisPlusConfig {

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
        paginationInnerInterceptor.setOptimizeJoin(true);// 优化join查询
        paginationInnerInterceptor.setDbType(DbType.MYSQL); //选择数据库类型
        paginationInnerInterceptor.setOverflow(false); //是否抛出异常
        interceptor.addInnerInterceptor(paginationInnerInterceptor);
        return interceptor;
    }

}